<%--
  Created by IntelliJ IDEA.
  User: zhangkeke
  Date: 2022/10/9
  Time: 18:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登入</title>
    <script src="../jcript/jquery-1.7.2.js"></script>
    <script src="./js/bootstrap.js"></script>
    <link rel="stylesheet" href="./css/bootstrap.css">
    <script>
        $(function (){
            $("#inp1").blur(function (){
                var reg = /^1[\d]{10}$/;
                if(!reg.test($("#inp1").val())){
                    $("#inp1").val("");
                }
            })
            $("#code_img").click(function (){
                this.src="http://localhost:8087/kaptcha.jpg"
            })
            /**弹窗，询问是否开户
             * 使用Ajax*/
            $("#sub").click(function (){
                var va11 =$("#inp1").val();
                var val2 = $("#inp2").val();
                var val3 = $("#code").val();
                $.ajax({
                    url:"/login",
                    data:{telephone:va11,password:val2,code:val3},
                    dataType:"json",
                    success:function (data){
                        if (data==1){
                            var flag = confirm("登入成功，是否前往开户?");
                            if (flag){
                                window.location.href="pages/account/account_open.jsp";
                            }else {
                                window.location.href="http://localhost:8087/showAccount";
                            }

                        }else if(data==0){
                            location.href="http://localhost:8087/pages/login/login.jsp"
                        }else if(data==2){
                            location.href="http://localhost:8087/pages/login/loginFail.jsp"
                        }else {
                            location.href="http://localhost:8087/pages/login/login.jsp"
                        }

                    }
                })
                // var flag = confirm("登入成功，是否前往开户?");
                // if(flag){
                //     window.location.href="http://localhost:8087/pages/account_open.jsp";
                // }else{
                //
                // }

            })
            $("label").css({"display":"inline-block","width":"80px","text-align":"right"})


        })
    </script>
</head>
<body>
<div style="position: relative;left: 550px;top: 150px">
    <h3>欢迎登入艾融金融登入页面</h3>
    <%--<form action="" method="post" >--%>
    <label>手机号</label>
    <input type="text" placeholder="请输入您的手机号" name="telephone" id="inp1"><br>
    <label>密码</label>
    <input type="password" placeholder="请输入您的密码" name="password" id="inp2"><br>
    <label>验证码</label>
    <input type="text" placeholder="请输入验证码" id="code" name="code"><img src="http://localhost:8087/kaptcha.jpg" id="code_img"><br>
    <%--    <input type="submit" value="" id="sub" >--%>
    <label>登入</label>
    <button id="sub">确认登入</button>
    <%--</form>--%>
    <%--<a href="/pages/login/register.jsp"  style="font-size: 25px;color: red">还没账户？点击注册</a>--%>

    <a href="/pages/login/register.jsp" class="btn btn-primary btn-lg active" role="button">还没账户？点击注册</a>
</div>





</body>
</html>
